package com.coolwen.spring.aop.base;

import java.util.Date;

/**
 * @author CoolWen
 * @version 2020-03-19 9:04
 */
public class CalFibonacciProxy implements ICalFibonacci {
    private ICalFibonacci icf;

    public CalFibonacciProxy(ICalFibonacci icf) {
        this.icf = icf;
    }

    @Override
    public long calFibonacciByLoop(long n) {
        long rel;
        long start = new Date().getTime();
        rel = icf.calFibonacciByLoop(n);
        long end = new Date().getTime();
        System.out.println("循环所需要的时间为：" + (end - start));
        return rel;
    }

    @Override
    public long calFibonacciByRecusion(long n) {
        long rel;
        long start = new Date().getTime();
        rel = icf.calFibonacciByRecusion(n);
        long end = new Date().getTime();
        System.out.println("迭代所需要的时间为：" + (end - start));
        return rel;
    }
}
